<?php
class Default_Model_Comment extends Zend_Db_Table_Abstract{
    protected $_name='comment';
    protected $_primary='comment_id';
    protected $_db;
    
    public function __construct(){
        $this->_db=Zend_Registry::get('db');
    }
    
    public function addComment($data)
    {
        $this->_db->insert('comment',$data);
    }
    
    public function getCommentByTourId($tour_id)
    {
        $user = array(
            'u.fullname',
            'u.avatar',
        );
        $comment = array(
            'c.comment_id',
            'c.term',
            'c.create_date',
        );
        $sql=$this->_db->select()
                  ->from('comment AS c', $comment)
                  ->join('user AS u', 'u.user_id = c.user_id', $user)
                  ->where('c.tour_id = ?', $tour_id)
                  ->where('c.status = 1')
                  ->order('c.comment_id DESC');
        $result=$this->_db->fetchAll($sql);
        return $result;
    }
    
    
}

?>